

package cn.Set;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Test {

	public static void main(String[] args) {
	
		Set<Student> set=new HashSet<Student>();
		Student stuDemo=new Student("zhangdan",19);

		//Even do this,set only contain one zhangdan object
		set.add(stuDemo);
		set.add(stuDemo);

		set.add(new Student("zhang3",13));
		set.add(new Student("li4",14));
		
		set.add(new Student("wang5",15));
		set.add(new Student("wang5",15));
		
		Iterator<Student> iter =set.iterator();
		 while(iter.hasNext()){
			 Student stu=iter.next();
			 System.out.println(stu.getName());
		 }
	}
}
